﻿using AvalondockTest.Views;
using Dataforge.PrismAvalonExtensions;
using Dataforge.PrismAvalonExtensions.Regions;
using Microsoft.Practices.Prism.MefExtensions.Modularity;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.ServiceLocation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace AvalondockTest
{
  [ModuleExport(typeof(HelloWorldModule))]
  public class HelloWorldModule : IModule //, INotifyPropertyChanged
  {
    [ImportingConstructor]
    public HelloWorldModule(IRegionManager regionManager)
    {
      _regionManager = regionManager;
    }

    public void Initialize()
    {
      IRegion r = RegionManager.Regions["DockingRegion"];
      r.Add(new DockingMetadata(DocumentView, new DocumentDockStrategy()) { Title = "Document 123" });
      r.Add(new DockingMetadata(ToolView, new SideDockStrategy(DockSide.Left, new GridLength(300))) { Title = "Some Tool", AutoHide = true });
      r.Add(new DockingMetadata(AnotherToolView, new NestedDockStrategy(DocumentView, NestedDockPosition.Bottom, new GridLength(70))) { Title = "Another Tool" });
      r.Add(new DockingMetadata(YetAnotherToolView, new NestedDockStrategy(ToolView, NestedDockPosition.Inside)) { Title = "Yet Another Tool" });

      //DocumentTitle = "Document 123";
    }




    IRegionManager _regionManager;
    public IRegionManager RegionManager
    {
      get { return _regionManager; }
    }

    [Import]
    DocumentView _documentView = null;
    public DocumentView DocumentView
    {
      get { return _documentView; }
    }

    [Import]
    AnotherToolView _anotherToolView = null;
    public AnotherToolView AnotherToolView
    {
      get { return _anotherToolView; }
    }

    [Import]
    YetAnotherToolView _yetAnotherToolView = null;
    public YetAnotherToolView YetAnotherToolView
    {
      get { return _yetAnotherToolView; }
    }

    [Import]
    ToolView _toolView = null;
    public ToolView ToolView
    {
      get { return _toolView; }
    }

    //string _documentTitle;
    //public string DocumentTitle
    //{
    //  get { return _documentTitle; }
    //  set
    //  {
    //    if (_documentTitle != value)
    //    {
    //      _documentTitle = value;
    //      OnPropertyChanged("DocumentTitle");
    //    }
    //  }
    //}

    //public event PropertyChangedEventHandler PropertyChanged;
    //void OnPropertyChanged(string property)
    //{
    //  if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(property));
    //}
  }
}
